


# 反转链表
class Solution:

    def reverseList(self, head):
        if not head:
            return None

        temp = []
        while head:

            temp.append(head)
            head = head.next
        
        ans = reHead = temp.pop()
        while temp:
            reHead.next = temp.pop()
            
            reHead = reHead.next

        reHead.next = None
        return ans
            